package com.ultisense.gassensor;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

import static android.content.Context.NOTIFICATION_SERVICE;

public class WarningNotification {

    Notification notification;
    NotificationManager notificationManager;

    public void startNotification(Context mContext, Class mClass){
        Intent intent=new Intent(mContext,mClass);
        PendingIntent pendingIntent=PendingIntent.getActivity(mContext,0,intent,0);
        Notification.Builder mBuilder=new Notification.Builder(mContext);

        mBuilder.setContentTitle("Smart Home")
                .setContentText("H2 Leakage detected!")
                .setTicker("Leakage detected")
                .setSmallIcon(R.mipmap.ic_launcher)
                .setDefaults(Notification.DEFAULT_LIGHTS)
                .setAutoCancel(true)
                .setContentIntent(pendingIntent);

        notification=mBuilder.build();
        notificationManager=(NotificationManager) mContext.getSystemService(NOTIFICATION_SERVICE);
        notificationManager.notify(1,notification);
    }
}
